export default class TimeUtil {
    public static millisecond(): number {
        return new Date().getTime()
    }

    public static unixtime(): number {
        return Math.floor(this.millisecond() / 1000)
    }

    public static async sleep(ms: number) {
        return new Promise(resolve => setTimeout(resolve, ms))
    }

    public static isSameDay(timestamp1: number, timestamp2: number): boolean {
        const day1 = Math.floor(timestamp1 / 86400)
        const day2 = Math.floor(timestamp2 / 86400)

        return day1 === day2
    }

    public static isToday(timestamp: number): boolean {
        return this.isSameDay(timestamp, this.unixtime())
    }
}
